package com.travelsky.airchina.boarding.dao.impl.hibernate;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.travelsky.airchina.boarding.dao.ProductSeriesDAO;
import com.travelsky.airchina.boarding.domain.ProductSeries;


@Repository("productSeriesDAO")
public class ProductSeriesDAOImpl extends GenericDAOHibernate<ProductSeries, Long,ProductSeriesDAO> implements ProductSeriesDAO {
	@Autowired
	public ProductSeriesDAOImpl(SessionFactory sessionFactory){
		this.setSessionFactory(sessionFactory);
	}
	@SuppressWarnings("unchecked")
	public List<ProductSeries> findProductSerieses(String status) {
		String hql = "from ProductSeries where status = ? order by sortOrder";
		return this.getHibernateTemplate().find(hql, status);
	}

	public void updateProductSeriesStatus(Long id, String status) {
		String hql = "update ProductSeries set status = ? where id = ?";
		this.getHibernateTemplate().bulkUpdate(hql, new Object[]{status,id});
	}
	
}
